var status = -1;
var selectionLog = [];
var rand;
var items = [1202274, 5044000, 2022740, 2022741, 2022742, 2022743, 2022744, 2022745, 4001832, 2028048, 2435719];
var nums = [1, 1, 5, 5, 5, 5, 5, 5, 100, 10, 5];

function start() {
    action(1, 0, 0)
}

function action(d, c, b) {
    if (im.getServerName().equals("BMS单机") && im.getServerName().equals("BMS至尊体验服") && !im.getServerName().equals("BMS至尊")) {
        im.playerMessage(1, " 使用环境异常，请还原服务端配置。");
        im.dispose();
        return
    }
    if (status == 0 && d == 0) {
        im.dispose();
        return
    }(d == 1) ? status++ : status--;
    selectionLog[status] = b;
    var a = -1;
    if (status <= a++) {
        im.dispose()
    } else {
        if (status === a++) {
            rand = im.rand(0, items.length - 1);
            im.sendNormalTalk("已获得如下奖励！#n\r\n\r\n#fUI/UIWindow2.img/QuestIcon/4/0#\r\n\r\n#b#i" + items[rand] + ":# #t" + items[rand] + ":##k", 16, 0, false, false)
        } else {
            if (status === a++) {
                im.gainItem(2630963, -1);
                im.gainItem(items[rand], nums[rand]);
                im.dispose()
            }
        }
    }
};